const constants     = require("../../data/constants");
const sipServer     = require('../../sip/server');
const log4js        = require('../../data/log');
const logger        = log4js.getLogger('request');

let gb28181={};

/**
 * 改变GB28181服务的状态
 * @param {*} req 
 * @param {*} res 
 */
gb28181.changeStatus=function(req,res){
    if(sipServer.running){
        sipServer.stop();
    }else{
        sipServer.start();
    }
    let ret=Object.assign(constants.httpCode.OK,{
        data:{"running":sipServer.running}
    });
    res.send(ret);
}
/**
 * 获取gb28181服务的状态
 * @param {*} req 
 * @param {*} res 
 */
gb28181.getStatus=function(req,res){
    let ret=Object.assign(constants.httpCode.OK,{
        data:{
            running: sipServer.running
        }
    });
    res.send(ret);
}
/**
 * 获取连接的gb28181客户端
 * @param {*} req 
 * @param {*} res 
 */
gb28181.getClients=function(req,res){
    let ret=Object.assign(constants.httpCode.OK,{
        data:constants.registry
    });
    res.send(ret);
}

module.exports=gb28181;